package n15.second;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

public class F01 {

	public static void main(String[] args) throws IOException {
		Path path = Paths.get("./src/n15/second/hello.txt");
		//Path path = Paths.get("src","n15","second/hello.txt");//和上面等效
		//(1)使用readAllBytes()返回字节数组
		byte[] bs = Files.readAllBytes(path);
		String s=new String(bs, "utf-8"); //"GBK"
		System.out.println(s);
		//(2)使用readAllLines()返回List
		List<String> ls = Files.readAllLines(path, Charset.forName("utf-8"));
		ls.forEach(System.out::println);
		//(3)使用lines()方法返回Stream
		Files.lines(path, Charset.forName("utf-8")).forEach(System.out::println);
	}

}
